<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>启动 xhprof 性能分析器</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.xhprof-enable" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">xhprof_enable</h1>
  <p class="verinfo">(PECL xhprof &gt;= 0.9.0)</p><p class="refpurpose"><span class="refname">xhprof_enable</span> &mdash; <span class="dc-title">启动 xhprof 性能分析器</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.xhprof-enable-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>xhprof_enable</strong></span>
    ([ <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = 0</span></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$options</code></span>
  ]] ) : <span class="type"><span class="type void">void</span></span></div>

  <p class="para rdfs-comment">
   启动 xhprof 进行性能分析。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.xhprof-enable-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">flags</code></dt>

     <dd>

      <p class="para">
       分析添加额外信息的可选标记。
       关于此标记的更多信息参见
       <a href="xhprof.constants.html" class="link">XHprof 常量</a>，例如，
       <strong><code>XHPROF_FLAGS_MEMORY</code></strong>
       可以开启内存的分析。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">options</code></dt>

     <dd>

      <p class="para">
       <span class="type"><a href="language.types.array.html" class="type array">array</a></span> 的可选选项，就是通过传递 &#039;ignored_functions&#039; 选项来忽略性能分析中的某些函数。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.xhprof-enable-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   <strong><code>NULL</code></strong>
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.xhprof-enable-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>0.9.2</td>
      <td>
       添加可选的 <code class="parameter">options</code> 参数。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>



 <div class="refsect1 examples" id="refsect1-function.xhprof-enable-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-639">
   <p><strong>Example #1 <span class="function"><strong>xhprof_enable()</strong></span> 范例</strong></p>
   <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;1.&nbsp;elapsed&nbsp;time&nbsp;+&nbsp;memory&nbsp;+&nbsp;CPU&nbsp;profiling;&nbsp;and&nbsp;ignore&nbsp;built-in&nbsp;(internal)&nbsp;functions<br /></span><span style="color: #0000BB">xhprof_enable</span><span style="color: #007700">(</span><span style="color: #0000BB">XHPROF_FLAGS_NO_BUILTINS&nbsp;</span><span style="color: #007700">|&nbsp;</span><span style="color: #0000BB">XHPROF_FLAGS_CPU&nbsp;</span><span style="color: #007700">|&nbsp;</span><span style="color: #0000BB">XHPROF_FLAGS_MEMORY</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;2.&nbsp;elapsed&nbsp;time&nbsp;profiling;&nbsp;ignore&nbsp;call_user_func*&nbsp;during&nbsp;profiling<br /></span><span style="color: #0000BB">xhprof_enable</span><span style="color: #007700">(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;array(</span><span style="color: #DD0000">'ignored_functions'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&nbsp;array(</span><span style="color: #DD0000">'call_user_func'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'call_user_func_array'</span><span style="color: #007700">)));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /></span><span style="color: #FF8000">//&nbsp;3.&nbsp;elapsed&nbsp;time&nbsp;+&nbsp;memory&nbsp;profiling;&nbsp;ignore&nbsp;call_user_func*&nbsp;during&nbsp;profiling<br /></span><span style="color: #0000BB">xhprof_enable</span><span style="color: #007700">(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">XHPROF_FLAGS_MEMORY</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;array(</span><span style="color: #DD0000">'ignored_functions'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&nbsp;array(</span><span style="color: #DD0000">'call_user_func'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'call_user_func_array'</span><span style="color: #007700">)));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.xhprof-enable-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="xhprof_disable.html" class="function" rel="rdfs-seeAlso">xhprof_disable()</a> - 停止 xhprof 分析器</span></li>
   <li class="member"><span class="function"><a href="xhprof_sample_enable.html" class="function" rel="rdfs-seeAlso">xhprof_sample_enable()</a> - 以采样模式启动 XHProf 性能分析</span></li>
   <li class="member"><span class="function"><a href="memory_get_usage.html" class="function" rel="rdfs-seeAlso">memory_get_usage()</a> - 返回分配给 PHP 的内存量</span></li>
   <li class="member"><span class="function"><a href="getrusage.html" class="function" rel="rdfs-seeAlso">getrusage()</a> - 获取当前资源使用状况</span></li>
  </ul>
 </div>

</div></div></div></body></html>